package com.neusoft.Shixun.controller;

import com.neusoft.Shixun.dto.OutgoingRequestWithClientDto;
import com.neusoft.Shixun.po.Bed;
import com.neusoft.Shixun.po.BedUsage;
import com.neusoft.Shixun.po.OutgoingRequest;
import com.neusoft.Shixun.po.ResponseBean;
import com.neusoft.Shixun.service.BedService;
import com.neusoft.Shixun.service.BedUsageService;
import com.neusoft.Shixun.service.OutgoingRequestService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@CrossOrigin("*")
@RequestMapping("/OutgoingRequestController")
public class OutgoingRequestController {

    @Autowired
    private OutgoingRequestService outgoingRequestService;

    @GetMapping
    public ResponseBean<List<OutgoingRequest>> getAllOutgoingRequests() {
        return outgoingRequestService.getAllOutgoingRequests();
    }


    @GetMapping("/getOutgoingRequests")
    //   条件查询
    public ResponseBean<List<OutgoingRequestWithClientDto>> getOutgoingRequests(
            @RequestParam(required = false) String clientName,
            @RequestParam(required = false) String isSelfCare) {
    return outgoingRequestService.getOutgoingRequests(clientName, isSelfCare);
    }

    @GetMapping("/getOutgoingRequestsByCareTakerId")
    //   健康管家查询自己服务客户的外出申请
    public ResponseBean<List<OutgoingRequestWithClientDto>> getOutgoingRequestsByCareTakerId(
            @RequestParam Integer careTakerId,
            @RequestParam(required = false) String clientName) {
        return outgoingRequestService.getOutgoingRequestsByCareTakerId(careTakerId, clientName);
    }

    @PostMapping("/passOutgoingRequest")
//    通过外出审核
    public ResponseBean<Integer> passOutgoingRequest(@RequestBody OutgoingRequest outgoingRequest) {
        return outgoingRequestService.passOutgoingRequest(outgoingRequest);
    }

    @GetMapping("/{id}")
    public ResponseBean<OutgoingRequest> getOutgoingRequestById(@PathVariable Integer id) {
        return outgoingRequestService.getOutgoingRequestById(id);
    }

    @PostMapping("/addOutgoingRequest")
//   健康管家提出外出申请
    public ResponseBean<Integer> addOutgoingRequest(@RequestBody OutgoingRequest outgoingRequest) {
        return outgoingRequestService.addOutgoingRequest(outgoingRequest);
    }

    @PutMapping("/updateOutgoingRequest")
//    登记归来时间
    public ResponseBean<Integer> updateOutgoingRequest(@RequestBody OutgoingRequest outgoingRequest) {
        return outgoingRequestService.updateOutgoingRequest(outgoingRequest);
    }

    @DeleteMapping("/{id}")
    public ResponseBean<Integer> deleteOutgoingRequest(@PathVariable Integer id) {
        return outgoingRequestService.deleteOutgoingRequest(id);
    }
}